<?php
  //Buffer larger content areas like the main page content
  ob_start();
  require_once("auth.php");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Suppliers</title>
<script type="text/javascript" src="js/validationsupp.js"></script>
<script>
var count=0;

function load(thediv, thefile) /* 2 parameters passed into here: the id of the div container and the name of the page to go to */
{  
    if (window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();
    }
    else
    {
        xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');  
    }
    xmlhttp.addEventListener("error", transferFailed, false);  
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            document.getElementById( thediv ).innerHTML = xmlhttp.responseText;
        }
    }  
 
   xmlhttp.open('GET', thefile, true);
    xmlhttp.send();
	    
}

function transferFailed(evt) {  
  alert("An error occurred while transferring the file.");  
}

</script>

</head>

<body>
<?php 
include("config.php");
if(isset($_REQUEST['id']))
{
$id=$_REQUEST['id'];
$data=mysql_query("select * from suppliers where SupplierID='$id'");
$no=mysql_num_rows($data);
if($no!=0)
{
	while($rec=mysql_fetch_assoc($data))
	{

?>
<form action="updatesuppliers.php" method="post"  enctype="multipart/form-data" id="frmsuplier">
<fieldset >
<legend >Update Suppliers </legend>
			<div id="status"></div>

<table width="80%" align="center">
<tr>
<td width="25%">Supplier Name:</td>
<td width="27%"><input type="hidden" name="id" value="<?php echo $id; ?>" /><input type="text" name="txtSupplierName" id="txtSupplierName"   value="<?php echo $rec['SupplierName']; ?>"></td>
<td width="21%">Company Name:</td>
<td width="27%"><input type="text" name="txtCompanyName" id="txtCompanyName"   value="<?php echo $rec['CompanyName']; ?>"></td>
</tr>
<tr>
<td>City:</td><td><input type="text" name="txtCity" id="txtCity"   value="<?php echo $rec['City']; ?>"></td>
<td>State:</td><td><input type="text" name="txtState" id="txtState"   value="<?php echo $rec['State']; ?>"></td>
</tr>
<tr>
<td>Address:</td><td><textarea id="textAdd" name="textAdd">  <?php echo $rec['Address']; ?></textarea></td>
<td>Country:</td><td><input type="text" name="txtCountry" id="txtCountry"   value="<?php echo $rec['Country']; ?>"></td>
</tr>
<tr>
<td>Postal Code:</td><td><input type="text" name="txtPostalCode" id="txtPostalCode"   value="<?php echo $rec['PostalCode']; ?>" onkeypress="return numbersonly(event);"></td>
<td>Phone:</td><td><input type="text" name="txtPhone" id="txtPhone"   value="<?php echo $rec['Phone']; ?>" onkeypress="return numbersonly(event);"></td>
</tr>
<tr>
<td>Email:</td><td><input type="text" name="txtEmail" id="txtEmail"   value="<?php echo $rec['Email']; ?>"></td>
<td>Type Goods:</td><td><input type="text" name="txtTypeGoods" id="txtTypeGoods"   value="<?php echo $rec['TypeGoods']; ?>"></td>
</tr>
<tr>
<td>Current Order Details </td><td><textarea id="textcurrOrderDetails" name="textcurrOrderDetails">  <?php echo $rec['Curr_Ord_Details']; ?></textarea></td>
<td>Coustomer ID:</td><td><select id="ddlCustomerId" name="ddlCustomerId" >
							<?php 
							$data1=mysql_query("select * from customers");
							$no1=mysql_num_rows($data1);
							if($no1>0)
							{
								while($rec1=mysql_fetch_assoc($data1))
								{

							?>
							<option value="<?php echo $rec1['serial']; ?>"><?php echo $rec1['name']; ?> </option>
							<?php
							}
							}
							?>
							
							</select></td>

</tr>
<tr>

<tr><td colspan="3"><input type="button" value="Update Suppliers" name="btnUpdateSuppliers"  onclick="validateForm2('updatesuppliers.php','frmShippers','thediv','<img src=\'pleasewait.gif\'>');" /></td></tr>
</table>


  </fieldset>
  	</form>
	<?php
	}
	}
	}
	else
	{
	?>
	<form action="addsuppliers.php" method="post"  enctype="multipart/form-data" id="frmsuplier">
<fieldset >
<legend style="color:#FD0002">Add Suppliers </legend>
<div id="status"></div>

<table width="80%" align="center">
<tr>
<tr>
<td width="25%">Supplier Name:<span style="color:#FF6600">*</span></td>
<td width="27%"><input type="text" name="txtSupplierName" id="txtSupplierName"   ></td>
<td width="21%">Company Name:<span style="color:#FF6600">*</span></td>
<td width="27%"><input type="text" name="txtCompanyName" id="txtCompanyName"   ></td>
</tr>
<tr>
<td>City:<span style="color:#FF6600">*</span></td><td><input type="text" name="txtCity" id="txtCity" ></td>
<td>State:<span style="color:#FF6600">*</span></td><td><input type="text" name="txtState" id="txtState"   ></td>
</tr>
<tr>
<td>Address:<span style="color:#FF6600">*</span></td><td><textarea id="textAdd" name="textAdd"> </textarea></td>
<td>Country:<span style="color:#FF6600">*</span></td><td><input type="text" name="txtCountry" id="txtCountry"  ></td>
</tr>
<tr>
<td>Postal Code:<span style="color:#FF6600">*</span></td><td><input type="text" name="txtPostalCode" id="txtPostalCode"  onkeypress="return numbersonly(event);" ></td>
<td>Phone:<span style="color:#FF6600">*</span></td><td><input type="text" name="txtPhone" id="txtPhone"  onkeypress="return numbersonly(event);"  ></td>
</tr>
<tr>
<td>Email:<span style="color:#FF6600">*</span></td><td><input type="text" name="txtEmail" id="txtEmail"  ></td>
<td>Type Goods:</td><td><input type="text" name="txtTypeGoods" id="txtTypeGoods"  ></td>
</tr>
<tr>
<td>Current Order Details </td><td><textarea id="textcurrOrderDetails" name="textcurrOrderDetails">  </textarea></td>
<td>Coustomer ID:</td><td><select id="ddlCustomerId" name="ddlCustomerId" >
							<?php 
							$data1=mysql_query("select * from customers");
							$no1=mysql_num_rows($data1);
							if($no1>0)
							{
								while($rec1=mysql_fetch_assoc($data1))
								{

							?>
							<option value="<?php echo $rec1['CustomerID']; ?>"><?php echo $rec1['CustomerName']; ?> </option>
							<?php 
							}
							}
							?>
							
							</select></td>

</tr>
<tr><td colspan="3">
		  <input type="button"  value="Add Supliers" onclick="validateForm2('addsuppliers.php','frmsupplier','thediv','<img src=\'pleasewait.gif\'>');" name="equirysubmit" id="equirysubmit" />
</td></tr>

</table>


  </fieldset>
  	</form>
	<?php
	}
	
	?>
	</body></html>
	 <?php
  //Assign all Page Specific variables
  $pagemaincontent = ob_get_contents();
  ob_end_clean();
  $pagetitle = "Suppliers";
  //Apply the template
  include("master.php");
?>
<?php ob_flush(); ?>